package org.xteam.sled.semantic;

import org.xteam.parser.runtime.Span;
import org.xteam.sled.model.BasePattern;
import org.xteam.sled.model.IField;
import org.xteam.sled.semantic.exp.Exp;


public class Field implements IDenotable, IField {

	private String name;
	private Range range;
	private TokenClass cls;

	public Field(String name, Range range, TokenClass cls) {
		this.name = name;
		this.range = range;
		this.cls = cls;
	}

	public String name() {
		return name;
	}
	
	public TokenClass cls() {
		return cls;
	}
	
	public int size() {
		return range.size();
	}

	public int fieldmax() {
		return 1<<(range.high()-range.low());
	}
	
	public String toString() {
		return name + range; 
	}

	@Override
	public Exp projectInt(IEvaluationContext context, Span span) {
		context.reportError(span, "not an integer expression");
		return null;
	}

	@Override
	public BasePattern projectPattern(IEvaluationContext context, Span span) {
		context.reportError(span, "not an pattern expression");
		return null;
	}

}
